{extend name='base' /}
{block name='content'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">日志管理</a>
        <a>
          <cite>登录日志列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" method="get">
            <input type="text" name="username" placeholder="请输入操作者" autocomplete="off" class="layui-input"
                   value="<?php echo $username = isset($_GET['username'])?$_GET['username']:'';?>">
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>

    </div>
    <xblock>
        <a href="javascript:allDel();" class="layui-btn layui-btn-danger"><i class="layui-icon layui-icon-delete"></i>清空登陆日志</a>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>操作人</th>
            <th>登录时间</th>
            <th>登陆IP</th>
        </thead>
        <tbody>
        {volist name='lists' id='vo'}
        <tr>
            <td>{$vo.log_id}</td>
            <td>{$vo.username}</td>
            <td>{$vo.log_time|date='Y-m-d H:i:s',###}</td>
            <td>{$vo.log_ip}</td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page">
        <div>
            {$lists->render()}
        </div>
    </div>

</div>
<script>

    /*用户-删除*/
    function allDel() {
        layer.confirm('确认要删除吗？', function (index) {
            // //发异步删除数据
            $.ajax({
                url: "{:url('log/allDel')}",
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code) {
                        layer.msg(res.message, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        },1000)
                    } else {
                        layer.msg(res.message, {icon: 2, time: 1000})
                    }
                },
                error: function () {
                    layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                }
            })

        });
    }


</script>

</body>
{/block}